package com.main.by.service.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.main.by.dao.TaskDao;
import com.main.by.entity.vo.NewsInfoVO;
import com.main.by.entity.vo.SubmitVO;
import com.main.by.entity.vo.TaskVO;
import com.main.by.service.TaskService;

@Service
public class TaskServiceImpl implements TaskService{
	
	private static Logger logger = Logger.getLogger(TaskServiceImpl.class);
	
	@Autowired
	private TaskDao taskDao;

	@Override
	public boolean addTaskInfo(TaskVO taskInfo, HttpServletRequest request,HttpServletResponse response) throws Exception {
		logger.info("发布任务");
		boolean successful = taskDao.insterTask(taskInfo);
		return successful;
	}
	
	@Override
	public List<TaskVO> findAllTask(HttpServletRequest request) throws Exception {
		logger.info("查询数据库");
		return  taskDao.findAllTask();
	}

	@Override
	public TaskVO findTaskById(int taskId) throws Exception {
			logger.info("查询数据库");
			return  taskDao.findTaskById(taskId);
	}

	@Override
	public boolean deleteTaskById(int taskId) throws Exception {
		logger.info("查询管理员数据库");
		return  taskDao.deleteTaskById(taskId);
	}

	@Override
	public boolean saveTaskInfo(TaskVO taskVO) throws Exception {
		logger.info("修改任务信息");
		return  taskDao.saveTaskInfo(taskVO);
	}

	@Override
	public boolean addSubmitTaskInfo(SubmitVO submitTaskInfo, HttpServletRequest request, HttpServletResponse response)throws Exception {
		logger.info("提交任务");
		boolean successful = taskDao.insterSubmitTask(submitTaskInfo);
		return successful;
	}
	
	@Override
	public List<TaskVO> selectTaskByCate(int taskId) throws Exception {
			logger.info("查询数据库");
			return  taskDao.selectTaskByCate(taskId);
	}
}
